<?php
 class Animal{//有些类或方法不需要继承，可用final进行限定。
	//内部外部都可访问
	public $nick;
	public $age;
	public $sex;
	//内部访问
	private $fly="我想飞";
	//类内部和子类
	protected $num=5;
	function __construct($nick,$age,$sex){
		//父类构造函数
		$this->nick=$nick;
		$this->age=$age;
		$this->sex=$sex;
	}
	function say(){
		echo $this->age."岁的",$this->sex,$this->nick."正在跑速度",$this->num."米每秒",$this->fly."<br/>";
	}
}

class Dog extends Animal{//继承要用关键字extends
    public $address;
	function __construct($nick,$age,$sex, $address){//子类构造函数
		//显示调用父类构造函数
		parent::__construct($nick,$age,$sex);
		$this->address=$address;
	}
	function move(){
		echo $this->address,$this->nick,"正在奔跑",$this->num;
	}
}
$erha=new Animal("二哈",3,"公");
$erha->say();
$xiaohua=new Dog("小花",2,"母","德国牧羊犬");
$xiaohua->move();

?>